package com.cotte.flow.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cotte.flow.kafka.Producer;

@RestController
@RequestMapping("/kafka")
public class KafkaController {

	@Autowired
	private Producer producer;
	
	@Value("${kafka.consumer.topic}")
	private String topic;
	
	@GetMapping("/send")
	public void testKafka() {
		/**
		 * {"计划编码":"XXXX","计划内容":
		 * [{"车间代码":"F1","系统单号":"0012:MXF,0101:MXF,04N0:MXF"},
		 * {"车间代码":"F2","系统单号":"3"},
		 * {"车间代码":"F3","系统单号":"2，，，，"}
		 * ]}
		 */
		String message ="{\r\n" + 
				"    \"JHBM\":\"XM181100405\",\r\n" + 
				"    \"JHNR\":[\r\n" + 
				"        {\r\n" + 
				"            \"CJDM\":\"F1\",\r\n" + 
				"            \"SCGGDH\":\"CU1810081454:MXF,CU1810311305:MXF,CU1811021718:MXF,CU1811040586:WXF,CU1811060484:WXF,CU1811071093:MXF,CU1811071248:MXF,CU1811080194:MXF,CU1811080506:MXF,CUI810100193:MXF,CUI811080005:MXF,CUI811080024:MXF,EUI810310026:MXF,EUR810220162:MXF,EUR810230024:MXF,EUR811050025:MXF,USA810200094:MXF,USA811070353:MXF,USA811080037:MXF,USA811080063:MXF,USI811090311:MXF,\"\r\n" + 
				"        },\r\n" + 
				"        {\r\n" + 
				"            \"CJDM\":\"B1\",\r\n" + 
				"            \"SCGGDH\":\"CU1811021718:MXK,CU1811071093:MXK,CU1811071248:MXK,CU1811080194:MXK,CU1811080506:MXK,CUI810100193:MXK,CUI811080005:MXK,CUI811080024:MXK,EUI810310026:MXK,USA810200094:MXK,USA811080037:MXK,USI811090010:MXK,USI811090028:MXK,USI811090030:MXK,USI811090031:MXK,USI811090038:MXK,USI811090051:MXK,USI811090172:MXK,USI811090173:MXK,USI811090255:MXK,\"\r\n" + 
				"        },\r\n" + 
				"        {\r\n" + 
				"            \"CJDM\":\"F2\",\r\n" + 
				"            \"SCGGDH\":\"USI811090003:MXF,USI811090004:MXF,USI811090010:MXF,USI811090028:MXF,USI811090030:MXF,USI811090031:MXF,USI811090038:MXF,USI811090051:MXF,USI811090058:MXF,USI811090094:MXF,USI811090131:MXF,USI811090132:MXF,USI811090172:MXF,USI811090173:MXF,USI811090186:MXF,USI811090255:MXF,\"\r\n" + 
				"        },\r\n" + 
				"        {\r\n" + 
				"            \"CJDM\":\"B2\",\r\n" + 
				"            \"SCGGDH\":\"USI811090003:MXK,USI811090004:MXK,USI811090058:MXK,USI811090094:MXK,USI811090131:MXK,USI811090132:MXK,USI811090186:MXK,\"\r\n" + 
				"        }\r\n" + 
				"    ]\r\n" + 
				"}";
		producer.send(topic, message);
	}
}
